-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global Styles: Expose the provider and the reset hook #42824
Conversation
Size Change: +34 B (0%) Total Size: 1.25 MB
ℹ️ View Unchanged
|
7783dac
to
ff24d88
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be documented here if it's being exposed as a public API?
I find this quite useful for the purposes of letting plugin developers interact with global styles, as demonstrated by WordPress/create-block-theme#96 !
Good idea, done! |
|
||
The `MyUIControls` component will now have access to the Global Styles store. | ||
|
||
## useGlobalStylesReset |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this hook is already documented above? :)
Oops you're right, it's gone! |
Would really love to see this land in 6.1 to enable tools like Create Block Theme to progress. Are there any reasons why this can't be brought in? |
Just need an approval from someone! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any problem with exposing this publicly—it seems pretty stable to me.
I would still like to hear from @oandregal or @jorgefilipecosta—they've both seen the major refactoring this component has gone through and may have some thoughts on the stability.
👋 My first instinct is that exporting only the two functions that are used by I know Jorge & Riad discussed options for extracting GS to its own package. Jorge has a wider view of the extensibility systems in place than I have. I'd like to here what his thoughts are before merging this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we are not ready to have a public global styles API yet. Right now, global styles are part of the edit site. As @oandregal referred, we may have a global styles package in the future, if we also include parts of global styles on edit-post.
I also imagine that if we are going to expose an API for global styles, we would not expose the provider and reset directly but instead expose a single hook that provides global styles value and a setter.
I imagine not having an API may be a blocker. I guess a possible intermediate step would be to expose a clearly experimental, internal, and unstable API so we can have some progress on WordPress/create-block-theme#96. |
04cf449
to
7a2cd10
Compare
Thanks for the feedback @jorgefilipecosta, I marked them as unstable... |
The exports should be named |
Closing this old PR. |
What?
This exports the GlobalStylesProvider component and the useGlobalStylesReset hook, so that plugins can interact with Global Styles.
Why?
This will be used in the create block theme plugin: WordPress/create-block-theme#96
How?
Simple - export these functions from the edit-site package.
Testing Instructions
See WordPress/create-block-theme#96
Screenshots or screencast